1. Field of the Invention
This invention relates generally to network servers and more particularly to servers that host a large number of client connections. Even more particularly, the present invention relates to servers (e.g., internet web servers) which host a large number of relatively slow client connections.
2. Description of the Background Art
It is common for network file servers such as internet web servers to host a large number of relatively slow client connections. The large number of open connections places a substantial burden on the server central processing unit (CPU), just to manage the open connections. For example, managing the open connections on a loaded server can consume 30-40% or more of the CPU""s operating capacity. This burden substantially reduces the percentage of CPU cycles available to perform the primary function of the server, i.e., providing data to clients.
The connection management burden on the server CPU degrades the performance of the server software routines and reduces the maximum number of client connections that can be open at one time. As a result, web-hosting companies must provide additional, redundant servers to serve an increased number of clients. The cost of acquiring and maintaining additional web servers is substantial.
Proxy servers perform some client connection management functions, and are known in the art. However, it is well-known and commonly accepted in the art that such proxy servers must be housed separately from the server, and thus must communicate with the server over relatively slow, error prone network connections which the server must manage. See for example, Ari Luotonen, Web Proxy Servers (Prentice Hall, 1997), which is incorporated herein by reference.
What is needed, therefore, is a system and method for relieving the server CPU of the connection management burden, thus allowing the server to more efficiently host an increased number of clients.
The present invention overcomes the problems associated with the prior art by providing a system and method for managing connections between a plurality of clients and a server. The invention facilitates off-loading the connection management burden from the host CPU to an adapter card interposed between the network and the host bus.
The adapter card includes a network controller, a memory device, a processing unit, and a protocol adapter. The memory device provides storage for data and code. The code includes a proxy application that communicates with clients on the network via the network controller, and communicates with the server via the protocol adapter, which is coupled directly to the server bus.
When executed by the processing unit, the proxy application manages client connections by establishing network connections between the proxy application and clients via the network, and by establishing bus connections between the proxy application and the server via the server bus. Additionally, the memory device provides data buffering, which allows many network connections to be open with clients, while a relatively few bus connections are open to the server. In a particular embodiment, the proxy accumulates client data in the buffers from the large number of slow client connections, and then submits the client data to the server over the fast bus connections. Conversely, the proxy receives server data via the fast bus connections, temporarily stores the server data, and then forwards the server data to the clients via the slow client connections.
In a more particular embodiment, the code includes a communications protocol stack that is employed by the application proxy to communicate with the clients and the server. In an even more particular embodiment, the communications protocol stack is a Transmission Control Protocol/Internet Protocol (TCP/IP) stack.
In one embodiment, the server connections are opened only after the proxy determines that a complete client request has been received. The server connections are then closed after the proxy receives a response to the client request from the server. Optionally, a predetermined number of persistent server connections are opened at system start-up, and the proxy uses these persistent connections to communicate with the server.
The proxy application optionally includes a number of application specific proxies, including but not limited to an HTTP proxy, a security proxy, and/or a pass-through proxy. In a particular embodiment, a master process module of the proxy discerns an application identifier (e.g., a well known port number) form the client data, and invokes one or more of the application specific proxies corresponding to the value of the identifier.
A system and method for allocating buffers is also disclosed, whereby the number of client connections that can be opened and managed by a proxy application is substantially increased. According to the method, buffers are allocated to a client connection only after it is determined that the buffer is needed to facilitate data transfer between a client and a server. One particular method includes the steps of establishing a connection with a client on behalf of a server, receiving a communication from the client, determining from the communication whether data will be exchanged between the client and the server (e.g., does the communication include a data request?), and allocating an input buffer to the client connection only if data is to be exchanged between the client and the server. Another particular method includes the steps of establishing a connection with a client on behalf of a server, receiving a communication from the client, determining whether data will be received from the server (e.g., whether a complete data request has been received from the client), and allocating an output buffer only if data is expected from the server.
A system and method for caching data from the server is also disclosed. A proxy application can then provide the cached data responsive to subsequent client requests without having to access the server again. In a particular embodiment, the system includes a network controller for communicating with clients on a network, a memory device for storing data and code, a processing unit coupled to the memory device for executing the code, a protocol adapter for providing communication between the processing unit and an internal bus of a server, and a cache memory. The code includes a proxy application that establishes network connections with clients, receives communications (e.g., data requests) from the clients via the network connection, establishes a bus connection with the server, forwards the client communication to the server via the bus connection, receives a response to the communication from the server, forwards the response to the client via the network connection, and selectively stores at least a portion of the response in the cache memory. Then, when the proxy application receives subsequent communications from clients requesting the same data, the proxy application can retrieve the data from the cache memory and transmit the data to the client, without accessing the server. Thus, the server is relieved from repeatedly receiving and responding to the same data request.
When the proxy application receives a response to a data request from the server on behalf of a client, the proxy application determines the cachability of the response before storing the response in the cache memory. The cachability of a response is determined by comparing at least a portion of the response (e.g., the protocol headers) to predetermined criteria. If the criteria are met, then the proxy application caches the response. If the cache memory is full, then the proxy application employs prioritizing routines (e.g., least-recently-used, frequency weighting, etc.) to determine which response(s) should be removed from the cache memory to make room for the new entry.
When the proxy application receives a data request from a client on behalf of the server, the proxy application determines whether the requested data is in the cache memory, and if the data is still valid. If the data is not in the cache memory, the proxy application forwards the request to the server. If the data is in the cache memory, the proxy application proceeds to determine if the data is valid. If the data is valid, the proxy application forwards the requested data to the client. If, however, the data is invalid, the proxy application removes the data from the cache memory and forwards the data request to the server.
In an exemplary embodiment, the methods of the present invention are implemented in an adapter card for coupling a server to a network.